let nums = [1,2,4,6,7,8]
function handle(nums, target) {
    let num =  0
    let map = new Map()
    for(let i in nums) {
        num = target - nums[i]
        if (map.has(num)) {
            return [map.get(num), i]
        }
        map.set(nums[i], i)
    }
}

let res = handle(nums, 11)
console.log(res)